package com.ruoyi.web.controller.warehouse;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WarehouseOutDetails;
import com.ruoyi.system.service.IWarehouseOutDetailsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出库明细表Controller
 * 
 * @author ruoyi
 * @date 2023-05-26
 */
@RestController
//@RequestMapping("/system/details")
public class WarehouseOutDetailsController extends BaseController
{
    @Autowired
    private IWarehouseOutDetailsService warehouseOutDetailsService;

    /**
     * 查询出库明细表列表
     */
    @PreAuthorize("@ss.hasPermi('system:details:list')")
    @GetMapping("/list")
    public TableDataInfo list(WarehouseOutDetails warehouseOutDetails)
    {
        startPage();
        List<WarehouseOutDetails> list = warehouseOutDetailsService.selectWarehouseOutDetailsList(warehouseOutDetails);
        return getDataTable(list);
    }

    /**
     * 导出出库明细表列表
     */
    @PreAuthorize("@ss.hasPermi('system:details:export')")
    @Log(title = "出库明细表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WarehouseOutDetails warehouseOutDetails)
    {
        List<WarehouseOutDetails> list = warehouseOutDetailsService.selectWarehouseOutDetailsList(warehouseOutDetails);
        ExcelUtil<WarehouseOutDetails> util = new ExcelUtil<WarehouseOutDetails>(WarehouseOutDetails.class);
        util.exportExcel(response, list, "出库明细表数据");
    }

    /**
     * 获取出库明细表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:details:query')")
    @GetMapping(value = "/{warehouseOutDetailsId}")
    public AjaxResult getInfo(@PathVariable("warehouseOutDetailsId") String warehouseOutDetailsId)
    {
        return success(warehouseOutDetailsService.selectWarehouseOutDetailsByWarehouseOutDetailsId(warehouseOutDetailsId));
    }

    /**
     * 新增出库明细表
     */
    @PreAuthorize("@ss.hasPermi('system:details:add')")
    @Log(title = "出库明细表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WarehouseOutDetails warehouseOutDetails)
    {
        return toAjax(warehouseOutDetailsService.insertWarehouseOutDetails(warehouseOutDetails));
    }

    /**
     * 修改出库明细表
     */
    @PreAuthorize("@ss.hasPermi('system:details:edit')")
    @Log(title = "出库明细表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WarehouseOutDetails warehouseOutDetails)
    {
        return toAjax(warehouseOutDetailsService.updateWarehouseOutDetails(warehouseOutDetails));
    }

    /**
     * 删除出库明细表
     */
    @PreAuthorize("@ss.hasPermi('system:details:remove')")
    @Log(title = "出库明细表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{warehouseOutDetailsIds}")
    public AjaxResult remove(@PathVariable String[] warehouseOutDetailsIds)
    {
        return toAjax(warehouseOutDetailsService.deleteWarehouseOutDetailsByWarehouseOutDetailsIds(warehouseOutDetailsIds));
    }
}
